import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from os.path import join,dirname
import numpy

import graph_common
import picture_detect
# 读取图片
name="2024-03-23-20-07-09-208404.png"
DIR = dirname(__file__)
path=join(DIR, "gray_scale_188_120", name)
img=mpimg.imread(path)

img_copy=img
# 备份用于处理
copy_img=[]
temp=[]
for i in range(0,188):
    for j in range(0,120):
        element_int =int(img_copy[j][i]*255)
        temp.append(element_int)
    copy_img.append(temp)
    temp=[]
# 转换为numpy数组
copy_copy_img=numpy.array(copy_img)
# print(copy_copy_img)

# laplace处理
kernel1=graph_common.laplacian_kernel()
output1_laplace=graph_common.laplacian(copy_copy_img,kernel1)
output1_laplace=output1_laplace.T

#select_area处理
output2_laplace=picture_detect.SelectArea(output1_laplace)

plt.subplot(2,2,1)
plt.imshow(img,cmap='gray')
plt.title("000")
plt.subplot(2,2,2)
plt.imshow(output1_laplace,cmap='gray')
plt.title("laplace")
plt.subplot(2,2,3)
plt.imshow(output2_laplace,cmap='gray')
plt.title("SelectArea")
plt.show()